<?php
namespace app\api\model;

use think\facade\Session;

class SubmitParam extends \think\Model
{

    /**
     * 获取单条
     * @param $id
     * @return array|null|\PDOStatement|string|\think\Model
     */
    public function _findOne($id){
        return $this->where([['id', '=', $id], ['status', '=', 1]])->find();
    }

    /**
    * 通过任务id获取参数
    * @param task_id int
    * @return array
    */
    public function _getList($task_id){
        $list =  $this->field('id, sid, title, skey, type, content')->where([['task_id', '=', $task_id], ['status', '=', 1]])->select()->toArray();
        
        foreach($list as $k=>$v){
            if($v['type'] == 3){
                $list[$k]['content'] = explode('|', $v['content']);
            }
        }
        
        return $list;
    }
}